-
-
Notifications
You must be signed in to change notification settings - Fork 354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
no-empty-file
: Added option to allow comments
#2300
base: main
Are you sure you want to change the base?
Conversation
no-empty-file
: Added option to allow comments
Thanks for contributing. There are linting issues that needs to be resolved. |
Hello! Can you please tell me how to fix linting issues? I tried running the command to update snapshots |
You need Node.js 20 to update snapshots eslint-plugin-unicorn/.github/workflows/main.yml Lines 44 to 45 in 231529a
|
Thank you! This helped solve the linting problem. Could you please help with "Integration Test 3"? Another PR has the same problem with this test. |
@fisker Hello, could you check this PR again please? |
rules/no-empty-file.js
Outdated
@@ -15,9 +15,17 @@ const isTripleSlashDirective = node => | |||
const hasTripeSlashDirectives = comments => | |||
comments.some(currentNode => isTripleSlashDirective(currentNode)); | |||
|
|||
const isProgramFileEmpty = node => node.type === 'Program' && node.body.length === 0; | |||
|
|||
const isAllowOnlyCommentsFile = (option, node) => option.allow.includes('comments') && isProgramFileEmpty(node); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have difficult to understand this, shouldn't it be something like allowComments && hasComment
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel /* comment */ {}
won't pass, but it should.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for review! I'll check it soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@AekoArray Bump |
docs/rules/no-empty-file.md
Outdated
} | ||
``` | ||
|
||
If you set it to `comments`, you can only store files with comments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sentence could be made more clear.
docs/rules/no-empty-file.md
Outdated
```js | ||
"unicorn/no-empty-file": { | ||
"allow": [ | ||
"comments" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tab-indentation
Maybe the option should be |
Yeah, I was thinking that too 👍 |
Can you remove |
|
||
## Options | ||
|
||
### allow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
### allow | |
### allowComments |
Hello, this is my first experience in open source. Could you see the implementation?
Fix #2218
Allow only comments in files